package com.chx.mapper;

import com.chx.entity.StockInOrderDetails;
import com.chx.entity.StockOutOrderDetails;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Author cp-月入过万
 * @Date 2025/5/31
 */
@Mapper
public interface StockOutOrderDetailMapper {
    @Insert("insert into stock_out_order_details(order_id, product_id, sale_price, quantity, subtotal)" +
            " values" +
            "(#{orderId},#{productId},#{salePrice},#{quantity},#{subtotal})")
    void insert(StockOutOrderDetails stockOutOrderDetails);

    @Delete( "delete from stock_out_order_details where order_id=#{orderId}")
    void delete(Long orderId);

    @Select( "select * from stock_out_order_details where order_id=#{orderId}")
    List<StockOutOrderDetails>  getByOrderId(Long orderId);

    @Select("select count(*) as total from stock_out_order_details where product_id=#{id}")
    int getByProductId(Long id);
}
